package _6运算符;

public class MathOperatorDemo
{

	public static void main(String[] args)
	{

		// 算数运算符
		// + - * / %
		
		int a = 39;
		int b = 20;
		int c;
		
		c = a+b;
		System.out.println("a+b="+c);
		c = a-b;
		System.out.println("a-b="+c);
		c = a*b;
		System.out.println("a*b="+c);
		c = a/b;// 两个整数之间进行运行，结果人就是整数
		System.out.println("a/b="+c);
		c = a%b;
		System.out.println("a%b="+c);
		
		float f1 = 11.0f;
		float f2 = 3.5f;
		System.out.println(f1+f2);
		System.out.println(f1-f2);
		System.out.println(f1*f2);
		System.out.println(f1/f2);
		System.out.println(f1%f2);
		

		// 多种数据类型运算
		int r = 5;
		float pi = 3.1415926F;
		float area = pi*r*r;
		System.out.println(area);
		
		
		// byte short char 在运算时会自动转换为int计算
		short s1 = 5;
		short s2 = 10;
		short result;
		result = (short)(s1+s2);
		System.out.println(result);

	}

}
